<div navbar ng-init="currentItem='site.nginx'"></div>
<div ng-show="!loaded">
    <div loading></div>
</div>

<div id="main" ng-show="loaded" style="display:none;">
    <div class="module-header">
        <h3>{{module_header}}</h3>
    </div>

    <div class="alert alert-danger" ng-show="!gen_by_inpanel" style="display:none;">
        <p>该站点的配置不是使用 InPanel 生成的，继续配置有可能导致部分配置丢失。</p>
        <p>建议使用 InPanel 为该站点新建一个配置，并将原配置迁移过来。</p>
        <p>如要手工编辑原始配置文件内容，请<a href="#/service/nginx?s=configfile">点击这里</a>。</p>
    </div>

    <div class="tabbable" ng-init="load()">
        <ul class="nav nav-tabs">
            <li ng-class="'active' | iftrue:activeTabName=='basic'"><a href="#basic" ng-click="sec('basic')" data-toggle="tab">基本设置</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='ssl'"><a href="#ssl" ng-click="sec('ssl')" data-toggle="tab">SSL</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='rewrite'"><a href="#rewrite" ng-click="sec('rewrite')" data-toggle="tab">重定向</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='advanced'"><a href="#advanced" ng-click="sec('advanced')" data-toggle="tab">高级设置</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='basic'" id="basic">
                <div class="form-horizontal form-horizontal-small">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">站点域名</label>
                        <div class="col-sm-10">
                            <div class="form-inline" ng-repeat="server_name in setting.server_names">
                                <input class="form-control" ng-model="server_name.name" type="text" ng-disabled="server_name.default_name" placeholder="请输入域名或IP">
                                <button class="btn btn-default" ng-click="deleteservername($index)" ng-show="setting.server_names.length>1" title="删除这个域名"><i class="glyphicon glyphicon-minus"></i></button>
                                <button class="btn btn-default" ng-click="addservername()" ng-show="$index==setting.server_names.length-1" title="增加一个域名"><i class="glyphicon glyphicon-plus"></i></button>
                                <label class="checkbox-inline">
                                    <input type="checkbox" ng-model="server_name.default_name" ng-click="server_name.name='_'"> 设置为任意域名可访问
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">站点路径</label>
                        <div class="col-sm-10">
                            <div class="form-inline">
                                <button class="btn btn-default" ng-click="addlocation($index)" ng-show="setting.locations.length==0" style="display:none">
                                    <i class="glyphicon glyphicon-plus"></i> 添加路径配置
                                </button>
                                <ul class="nav nav-tabs" ng-show="setting.locations.length>0" style="display:none;">
                                    <li ng-repeat="location in setting.locations" ng-class="'active'|iftrue:$index==curloc" ng-click="setloc($index)">
                                        <a href="#loc_{{$index}}" data-toggle="tab">{{location.urlpath}}</a>
                                    </li>
                                    <li>
                                        <button class="btn btn-default" ng-click="addlocation()" style="margin-left: 20px; margin-top: 5px;">
                                            <i class="glyphicon glyphicon-plus"></i> 添加路径
                                        </button>
                                        <button class="btn btn-default" ng-click="deletelocation(curloc)" style="margin-left: 10px; margin-top: 5px;">
                                            <i class="glyphicon glyphicon-minus"></i> 删除路径
                                        </button>
                                    </li>
                                </ul>
                                <div class="tab-content" ng-show="setting.locations.length>0" style="display:none;">
                                    <div class="tab-pane" ng-repeat="location in setting.locations" ng-class="'active'|iftrue:$index==curloc" id="loc_{{$index}}">
                                        <div class="form-inline">
                                            <label class="col-sm-2 control-label">URL路径</label>
                                            <div class="controls">
                                                <input class="form-control" ng-model="location.urlpath" ng-change="urlpathchange(location)" type="text" placeholder="URL路径">
                                            </div>
                                        </div>
                                        <div class="form-inline">
                                            <label class="col-sm-2 control-label">引擎类别</label>
                                            <div class="controls">
                                                <select class="form-control" ng-model="location.engine">
                                                    <option value="static">纯静态</option>
                                                    <option value="fastcgi">FastCGI(PHP)</option>
                                                    <option value="redirect">跳转</option>
                                                    <option value="proxy">反向代理</option>
                                                    <option value="error">返回错误</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='static'">
                                            <label class="col-sm-2 control-label">指定目录</label>
                                            <div class="controls">
                                                <div class="input-group">
                                                    <input ng-model="location.static.root" type="text" class="form-control" placeholder="路径所访问的目录">
                                                    <span class="input-group-btn">
                                                        <button class="btn btn-default" ng-click="selectstaticfolder($index)">
                                                            <i class="glyphicon glyphicon-folder-open"></i>
                                                        </button>
                                                    </span>
                                                </div>
                                                <p>
                                                    <label class="checkbox-inline"><input ng-model="location.static.autocreate" type="checkbox">目录不存在时，自动创建目录</label><br>
                                                    <label class="checkbox-inline"><input ng-model="location.static.autoindex" type="checkbox">开启目录自动索引</label>
                                                </p>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='fastcgi'">
                                            <label class="col-sm-2 control-label">指定目录</label>
                                            <div class="controls">
                                                <div class="input-group">
                                                    <input class="form-control" ng-model="location.fastcgi.root" type="text" placeholder="路径所访问的目录">
                                                    <span class="input-group-btn">
                                                        <button class="btn btn-default" ng-click="selectfastcgifolder($index)">
                                                            <i class="glyphicon glyphicon-folder-open"></i>
                                                        </button>
                                                    </span>
                                                </div>
                                                <p><label class="checkbox-inline"><input ng-model="location.fastcgi.autocreate" type="checkbox">目录不存在时，自动创建目录</label></p>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='fastcgi'">
                                            <label class="col-sm-2 control-label">FastCGI</label>
                                            <div class="controls">
                                                <input class="form-control" ng-model="location.fastcgi.fastcgi_pass" type="text" placeholder="FastCGI服务器地址">
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='redirect'">
                                            <label class="col-sm-2 control-label">跳转地址</label>
                                            <div class="controls">
                                                <input class="form-control" ng-model="location.redirect.url" type="text" placeholder="要跳转到的URL地址">
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='redirect'">
                                            <label class="col-sm-2 control-label">跳转类型</label>
                                            <div class="controls">
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.redirect.type" value="301"> 301永久重定向
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.redirect.type" value="302"> 302临时重定向
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='redirect'">
                                            <label class="col-sm-2 control-label">路径处理</label>
                                            <div class="controls">
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.redirect.option" value="keep"> 保留请求路径
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.redirect.option" value="ignore"> 忽略请求路径
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'">
                                            <label class="col-sm-2 control-label">后端协议</label>
                                            <div class="controls">
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.proxy.protocol" value="http"> http
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.proxy.protocol" value="https"> https
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'">
                                            <label class="col-sm-2 control-label">主机域名</label>
                                            <div class="controls">
                                                <input ng-model="location.proxy.host" type="text" class="form-control" placeholder="后端的域名，如：www.baidu.com">
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'">
                                            <label class="col-sm-2 control-label">真实IP</label>
                                            <div class="controls">
                                                <label class="checkbox-inline">
                                                    <input type="checkbox" ng-model="location.proxy.realip"> 传递客户端真实IP（X-Real-IP）
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'">
                                            <label class="col-sm-2 control-label">后端编码</label>
                                            <div class="controls">
                                                <select class="form-control" ng-model="location.proxy.charset">
                                                    <option value="">默认</option>
                                                    <option value="utf-8">UTF-8</option>
                                                    <option value="gb2312">GB2312</option>
                                                    <option value="gbk">GBK</option>
                                                    <option value="gb18030">GB18030</option>
                                                    <option value="big5">BIG5</option>
                                                    <option value="euc-jp">EUC-JP</option>
                                                    <option value="euc-kr">EUC-KR</option>
                                                    <option value="iso-8859-2">ISO-8859-2</option>
                                                    <option value="shift_jis">Shift_JIS</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div ng-show="location.engine=='proxy'" ng-repeat="backend in location.proxy.backends">
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label"><span ng-show="$index==0">代理后端</span></label>
                                                <div class="controls">
                                                    <input ng-model="backend.server" type="text" class="form-control" placeholder="格式为：IP:端口 或 域名:端口">
                                                    <input ng-model="backend.weight" type="text" class="form-control" placeholder="权重值" ng-show="location.proxy.backends.length>1&&location.proxy.balance=='weight'">
                                                    <button class="btn btn-default" title="删除该后端" ng-click="proxy_deletebackend($parent.$index, $index)" ng-show="location.proxy.backends.length>1"><i class="glyphicon glyphicon-minus"></i></button>
                                                    <button class="btn btn-default" title="增加一个后端" ng-click="proxy_addbackend($parent.$index)" ng-show="$index==location.proxy.backends.length-1"><i class="glyphicon glyphicon-plus"></i></button>
                                                </div>
                                            </div>
                                            <div class="form-inline" ng-show="location.proxy.backends.length>1">
                                                <div class="controls">
                                                    失效条件：<input ng-model="backend.fail_timeout" type="text" class="form-control"> 秒内失败
                                                    <input ng-model="backend.max_fails" type="text" class="form-control"> 次
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'&&location.proxy.backends.length>1">
                                            <label class="col-sm-2 control-label">负载均衡</label>
                                            <div class="controls">
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.proxy.balance" value="weight"> 按权重分配
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" ng-model="location.proxy.balance" value="ip_hash"> 根据IP自动分配
                                                </label>
                                                <label class="radio-inline" ng-show="true | ifverget:[nginx_version, '1.3.1']">
                                                    <input type="radio" ng-model="location.proxy.balance" value="least_conn"> 最少连接优先分配
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'&&location.proxy.backends.length>1">
                                            <label class="col-sm-2 control-label">保持连接</label>
                                            <div class="controls">
                                                <input ng-model="location.proxy.keepalive" type="text" class="form-control" placeholder="到后端保持的连接数">
                                                <span class="help-block">这里设置的是保持连接的最大数量，而不是允许连接的数量，最大连接数量不受限制。</span>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='proxy'">
                                            <label class="col-sm-2 control-label">缓存设置</label>
                                            <div class="controls">
                                                <label class="checkbox-inline">
                                                    <input type="checkbox" ng-model="location.proxy.proxy_cache_enable"> 启用反向代理缓存
                                                </label>
                                            </div>
                                        </div>
                                        <div ng-show="location.engine=='proxy'&&location.proxy.proxy_cache_enable" style="margin-left:70px">
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">缓存区域</label>
                                                <div class="controls">
                                                    <select class="form-control" style="width:150px" ng-model="location.proxy.proxy_cache" ng-options="cache for cache in proxy_caches"></select>
                                                    <button class="btn btn-default" title="重新加载" ng-click="loadproxycaches()"><i class="glyphicon glyphicon-refresh"></i></button>
                                                    <span class="help-block">如尚未创建缓存区，请<a href="#/service/nginx?s=proxy" target="_blank">点此设定</a>。</span>
                                                </div>
                                            </div>
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">缓存条件</label>
                                                <div class="controls">
                                                    至少请求 <input type="text" class="form-control" ng-model="location.proxy.proxy_cache_min_uses"> 次后才缓存资源
                                                </div>
                                            </div>
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">请求类型</label>
                                                <div class="controls">
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" checked disabled> GET
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" checked disabled> HEAD
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_methods_post"> POST
                                                    </label>
                                                    <span class="help-block">缓存以上选中的请求类型。</span>
                                                </div>
                                            </div>
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">资源标识</label>
                                                <div class="controls">
                                                    <label class="checkbox-inline"><input type="checkbox" ng-model="location.proxy.proxy_cache_key.schema"> 协议</label>
                                                    <label class="checkbox-inline"><input type="checkbox" ng-model="location.proxy.proxy_cache_key.host"> 主机名</label>
                                                    <label class="checkbox-inline"><input type="checkbox" ng-model="location.proxy.proxy_cache_key.proxy_host"> 后端主机名</label>
                                                    <label class="checkbox-inline"><input type="checkbox" ng-model="location.proxy.proxy_cache_key.uri"> 请求路径</label>
                                                    <span class="help-block">缓存资源的唯一性将由以上组合确定。</span>
                                                </div>
                                            </div>
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">缓存过期</label>
                                                <div class="controls">
                                                    <button class="btn btn-default" ng-click="proxy_addvalid($index)" ng-show="location.proxy.proxy_cache_valid.length==0"><i class="glyphicon glyphicon-plus"></i> 新增缓存过期配置</button>
                                                    <div ng-repeat="valid in location.proxy.proxy_cache_valid">
                                                        状态码：
                                                        <select class="form-control" style="width:80px;" ng-model="valid.code">
                                                            <option value="any">所有</option>
                                                            <option value="200">200</option>
                                                            <option value="301">301</option>
                                                            <option value="302">302</option>
                                                            <option value="404">404</option>
                                                            <option value="500">500</option>
                                                            <option value="502">502</option>
                                                            <option value="503">503</option>
                                                            <option value="504">504</option>
                                                        </select>，过期时间：
                                                        <input class="form-control" type="text" ng-model="valid.time" style="width: 60px;">
                                                        <select class="form-control" ng-model="valid.time_unit">
                                                            <option value="s">秒</option>
                                                            <option value="m">分钟</option>
                                                            <option value="h">小时</option>
                                                            <option value="d">天</option>
                                                        </select>
                                                        <button class="btn btn-default" title="删除该行" ng-click="proxy_deletevalid($parent.$index, $index)"><i class="glyphicon glyphicon-minus"></i></button>
                                                        <button class="btn btn-default" title="新增一行" ng-click="proxy_addvalid($parent.$index)" ng-show="$index==location.proxy.proxy_cache_valid.length-1"><i class="glyphicon glyphicon-plus"></i></button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-inline">
                                                <label class="col-sm-2 control-label">旧缓存</label>
                                                <div class="controls">
                                                    <span style="margin-top:3px;margin-bottom:0px;display:block">在以下情况下，直接使用旧的缓存：</span>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.error"> 连接后端出错
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.timeout"> 连接后端超时
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.invalid_header"> 后端返回错误
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.updating"> 缓存正在更新
                                                    </label><br>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.http_500"> 后端 500 错误 
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.http_502"> 后端 502 错误 
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.http_503"> 后端 503 错误 
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.http_504"> 后端 504 错误 
                                                    </label>
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" ng-model="location.proxy.proxy_cache_use_stale.http_404"> 后端 404 错误 
                                                    </label>
                                                </div>
                                            </div>
                                            <div class="form-inline" ng-show="true | ifverget:[nginx_version, '1.1.12']">
                                                <label class="col-sm-2 control-label">并发锁定</label>
                                                <div class="controls">
                                                    <p><label class="checkbox-inline"><input type="checkbox" ng-model="location.proxy.proxy_cache_lock"> 启用并发锁定</label></p>
                                                    <div class="input-group">
                                                        <input type="text" class="form-control" ng-disabled="!location.proxy.proxy_cache_lock" ng-model="location.proxy.proxy_cache_lock_timeout">
                                                        <span class="input-group-addon">秒</span>
                                                    </div>
                                                    <span class="help-block">并发锁定可防止多个相同请求向后端请求同一资源。</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='error'">
                                            <label class="col-sm-2 control-label">错误代码</label>
                                            <div class="controls">
                                                <select class="form-control" ng-model="location.error.code">
                                                    <option value="401">401 - 未授权的访问</option>
                                                    <option value="403">403 - 禁止访问</option>
                                                    <option value="404">404 - 页面无法找到</option>
                                                    <option value="500">500 - 服务器内部错误</option>
                                                    <option value="502">502 - 网关错误</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='static'">
                                            <label class="checkbox-inline">
                                                <input ng-model="location.static.rewrite_enable" ng-disabled="processing" type="checkbox">在该路径下启用 Rewrite
                                            </label>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='static' && location.static.rewrite_enable" style="display:none">
                                            <label class="checkbox-inline">
                                                <input ng-model="location.static.rewrite_detect_file" ng-disabled="processing" type="checkbox">仅当文件不存在时启用 Rewrite
                                            </label>
                                        </div>
                                        <div class="form-inline" ng-show="location.engine=='static' && location.static.rewrite_enable" style="display:none">
                                            <textarea class="form-control" ng-model="location.static.rewrite_rules" style="width:100%;height:100px;margin-top:5px;"></textarea>
                                            <p><a href="https://docs.inpanel.org/?sec=nginx_rewrite" target="_blank">常用 Rewrite 规则参考</a></p>
                                        </div>
                                        <div class="form-inline" style="margin-top:5px;margin-bottom:0" ng-show="location.engine=='fastcgi'">
                                            <label class="col-sm-2 control-label">Rewrite</label>
                                            <div class="controls">
                                                <label class="checkbox-inline">
                                                    <input ng-model="location.fastcgi.rewrite_enable" ng-disabled="processing" type="checkbox">在该路径下启用 Rewrite
                                                </label>
                                            </div>
                                        </div>
                                        <div class="form-inline" ng-show="location.fastcgi.rewrite_enable" style="display:none">
                                            <div class="controls">
                                                <label class="checkbox-inline">
                                                    <input ng-model="location.fastcgi.rewrite_detect_file" ng-disabled="processing" type="checkbox">
                                                    仅当文件不存在时启用 Rewrite
                                                </label><br>
                                                <textarea class="form-control" ng-model="location.fastcgi.rewrite_rules" style="width:100%;height:100px;margin-top:5px;"></textarea>
                                                <br><a href="https://docs.inpanel.org/?sec=nginx_rewrite" target="_blank">常用 Rewrite 规则参考</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='ssl'" id="ssl">
                <div class="form-horizontal form-horizontal-small">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">SSL 开关</label>
                        <div class="col-sm-10">
                            <div class="btn-group">
                                <button class="btn btn-default" ng-class="'active' | iftrue: ssl_enabled" ng-click="ssl_status_set(true)" title="统一打开 SSL">打开</button>
                                <button class="btn btn-default" ng-class="'active' | iftrue: !ssl_enabled" ng-click="ssl_status_set(false)" title="统一关闭 SSL">关闭</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">SSL 证书</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <div class="input-group-btn">
                                    <button class="btn btn-default" ng-click="selectsslcrt()" title="选择证书文件"><i class="glyphicon glyphicon-folder-open"></i></button>
                                </div>
                                <input ng-model="setting.ssl_crt" type="text" class="form-control" placeholder="SSL 证书文件路径">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">SSL 密钥</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <div class="input-group-btn">
                                    <button class="btn btn-default" ng-click="selectsslkey()" title="选择密钥文件"><i class="glyphicon glyphicon-folder-open"></i></button>
                                </div>
                                <input ng-model="setting.ssl_key" type="text" class="form-control" placeholder="SSL 密钥文件路径">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='rewrite'" id="rewrite">
                <div class="form-horizontal form-horizontal-small">
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">Rewrite</label>
                        <div class="col-sm-10">
                            <div class="form-inline" style="margin-bottom:10px;">
                                <label class="checkbox-inline"><input ng-model="setting.rewrite_enable" type="checkbox">启用全局 Rewrite</label>
                            </div>
                            <div class="form-inline" style="margin-bottom:10px;">
                                <select class="form-control" ng-model="rewrite_template" ng-disabled="!setting.rewrite_enable">
                                    <option value="">常用 Rewrite 规则</option>
                                    <option value="301_1">301跳转，保留原路径</option>
                                    <option value="301_2">301跳转，不保留原路径</option>
                                    <option value="302_1">302跳转，保留原路径</option>
                                    <option value="302_2">302跳转，不保留原路径</option>
                                </select>
                            </div>
                            <div class="form-inline" style="margin-bottom:10px;">
                                <textarea class="form-control" ng-model="setting.rewrite_rules" ng-disabled="!setting.rewrite_enable" style="width:100%;height:100px;"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='advanced'" id="advanced">
                <div class="form-horizontal form-horizontal-small">
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">下载限制</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input class="form-control" ng-model="setting.limit_rate" type="text" placeholder="不限制">
                                <span class="input-group-addon">KB / S</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">连接限制</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input class="form-control" ng-model="setting.limit_conn" type="text" placeholder="不限制">
                                <span class="input-group-addon">个 / IP</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">默认编码</label>
                        <div class="col-sm-10">
                            <select class="form-control" ng-model="setting.charset">
                                <option value="">默认</option>
                                <option value="utf-8">UTF-8</option>
                                <option value="gb2312">GB2312</option>
                                <option value="gbk">GBK</option>
                                <option value="gb18030">GB18030</option>
                                <option value="big5">BIG5</option>
                                <option value="euc-jp">EUC-JP</option>
                                <option value="euc-kr">EUC-KR</option>
                                <option value="iso-8859-2">ISO-8859-2</option>
                                <option value="shift_jis">Shift_JIS</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">首页文件</label>
                        <div class="col-sm-10">
                            <input class="form-control" ng-model="setting.index" type="text">
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">监听地址</label>
                        <div class="col-sm-10">
                            <div ng-repeat="listen in setting.listens">
                                <div class="input-group">
                                    <input class="form-control" ng-model="listen.ip" type="text" placeholder="默认监听所有可用IP">
                                    <div class="input-group-addon" style="border-left: none;border-right:none;">:</div>
                                    <input class="form-control" ng-model="listen.port" type="text" placeholder="端口">
                                    <div class="input-group-btn">
                                        <button class="btn btn-default" ng-click="deletelisten()" ng-disabled="setting.listens.length<2" title="删除监听地址"><i class="glyphicon glyphicon-minus"></i></button>
                                        <button class="btn btn-default" ng-click="addlisten()" title="增加监听地址"><i class="glyphicon glyphicon-plus"></i></button>
                                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">端口 <span class="caret"></span></button>
                                        <ul class="dropdown-menu dropdown-menu-right">
                                            <li><a href="javascript:void(0);" ng-click="listen.port='80'">80</a></li>
                                            <li><a href="javascript:void(0);" ng-click="listen.port='81'">81</a></li>
                                            <li><a href="javascript:void(0);" ng-click="listen.port='443'">443</a></li>
                                            <li><a href="javascript:void(0);" ng-click="listen.port='8080'">8080</a></li>
                                            <li><a href="javascript:void(0);" ng-click="listen.port='8899'">8899</a></li>
                                            <li><a href="javascript:void(0);" ng-click="listen.port='9090'">9090</a></li>
                                            <!-- <li role="separator" class="divider"></li> -->
                                        </ul>
                                    </div>
                                </div>
                                <p class="form-inline">
                                    <label class="checkbox-inline"><input ng-model="listen.ssl" type="checkbox">启用SSL加密（https）</label>
                                    <label class="checkbox-inline"><input ng-model="listen.default_server" type="checkbox">作为默认站点</label>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <hr/>
        <p>
            <button class="btn btn-primary" ng-click="submit()">提交</button>
            <button class="btn btn-success" ng-click="submit('active')">生效</button>
            <button class="btn btn-warning" ng-show="action=='edit'" ng-click="restore()">重置</button>
            <a class="btn btn-default" href="#/site?s=nginx">取消</a>
        </p>
    </div>
</div>

<div id="selector" class="modal fade">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">{{selector_title}}</h3>
            </div>
            <div class="modal-body">
                <div selector></div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">取消</button>
            </div>
        </div>
    </div>
</div>